import 'package:flutter/cupertino.dart';
import 'package:ones/ui.dart';
import 'package:provider/provider.dart';

import '../../../../lib_basemodel/chat_room/kh_chat_room_seat_model.dart';
import '../../../../lib_baseview/theme/jr.dart';
import '../../../../lib_baseview/widget/avarar_image.dart';
import 'gift_page_model.dart';

class GiftUserWidget extends StatelessWidget {
  final KHChatRoomSeatModel user;
  final bool selected;
  final VoidCallback? onPressed;

  const GiftUserWidget({
    required this.user,
    required this.selected,
    this.onPressed,
  });

  @override
  Widget build(BuildContext context) {
    return Consumer<GiftPageModel>(
      builder: (BuildContext context, GiftPageModel model, child) {
        // int heart =
        //     model.getOtherHeartWithUid(NumUtil.parseInt(user.userId, -1));
        return Stack(
          // clipBehavior: Clip.none,
          // alignment: AlignmentDirectional.bottomCenter,
          alignment: Alignment.center,
          children: [
            CupertinoButton(
              onPressed: onPressed,
              minSize: 0,
              padding: const EdgeInsets.symmetric(horizontal: 6),
              child: AvatarImage(
                url: user.micUser?.headPortraitsUrl,
                width: 28,
                height: 28,
                borderRadius: 28 / 2,
              ),
            ),
            if (selected)
              JR
                  .img(
                'room/room_gift_select_icon.png',
                width: 34,
                height: 34,
              )
                  .onClick(() {
                onPressed?.call();
              })
          ],
        );
      },
    );
  }
}
